﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<CodeCamp.Models.Attendees.AttendeesPicksViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	<%= Html.Encode( Model.EventDisplayName ) %> | Session Picks for <%= Html.Encode( Model.AttendeeName ) %>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

  <p>
    To help Portland Code Camp select sessions and allocate rooms,
    please select up to  six session you would most like to attend. 
  </p>
    
  <h2>Session Picks for <%= Html.Encode( Model.AttendeeName ) %></h2>

  <% if ( Model.PickedSessions.Count == 0 )
     { %><i>Pick from the sessions listed below and select <b>Save my picks</b></i><% }
     else
     { %>
        <ul>
          <% foreach ( var session in Model.PickedSessions )
              { %>
                <li><%= Html.ActionLink( session.Title, "Details", "Sessions", new { id = session.SessionId }, null )%></li>
          <% } %>
        </ul>
  <% } %>

  <%  if ( Model.IsAttendeeAnonymous )
      { 
        using ( Html.BeginForm( "PicksAnonymousAttendeeRename", "Attendees" ) )
        { %>
          <h3>Rename the current anonymous user</h3>
          <p>
            You are currently an anonymous user.
            Create a memorable and individual name such as your email address,
            and use that name to review or edit your session picks later.
            <fieldset>
              <%= Html.Hidden( "AttendeeId", Model.AttendeeId ) %>
              Rename this user:
              <%= Html.TextBox( "AttendeeName", Model.AttendeeName ) %>
              <%= Html.ValidationMessage( "AttendeeName", "*" ) %>
              <input type="submit" value="Set user name" />
            </fieldset>
          </p>      
     <% }
      } %>

  <h3>Change to a different user</h3>
  <% using ( Html.BeginForm( "PicksChangeAttendee", "Attendees" ) )
      { %>
          <fieldset>
            <p>
              <%= Html.Hidden( "AttendeeId", Model.AttendeeId )%>
              Change attendee:
              <%= Html.TextBox( "AttendeeName", Model.AttendeeName )%>
              <%= Html.ValidationMessage( "AttendeeName", "*" )%>
              <input type="submit" value="Change attendee" />
            </p>
          </fieldset>
  <% } %>

  <h2>Pick the sessions you most want to attend</h2>
    
  <div>
    <% using ( Html.BeginForm() )
       { %>
        <fieldset>
          <%= Html.Hidden( "AttendeeId", Model.AttendeeId )%>
          <input type="submit" value="Save my picks" /><br />
          <%  int column1Count = Convert.ToInt32( Math.Floor( (Model.Sessions.Count + 1) / 2.0 ) ); 
              int index = 0; %>

          <div>
            <div style="float:left; width: 48%;">
              <% for ( index = 0; index < column1Count; ++index )
                 {
                    var session = Model.Sessions[ index ]; %>
                    <input type="checkbox" name="pickedSessions"
                            value="<%= Html.Encode( session.SessionId ) %>" 
                            <% if ( Model.PickedSessions.Exists( ps => ps.SessionId == session.SessionId ) )
                                { %>
                                checked="checked"
                            <% } %>
                    /><%= Html.ActionLink( session.Title, "Details", "Sessions", new { id = session.SessionId }, null )%><br />
              <% } %>
            </div>
            <div style="float: right; width: 48%;">
              <% for ( index = column1Count; index < Model.Sessions.Count; ++index )
                 {
                    var session = Model.Sessions[ index ]; %>
                    <input type="checkbox" name="pickedSessions"
                            value="<%= Html.Encode( session.SessionId ) %>" 
                            <% if ( Model.PickedSessions.Exists( ps => ps.SessionId == session.SessionId ) )
                                { %>
                                checked="checked"
                            <% } %>
                    /><%= Html.ActionLink( session.Title, "Details", "Sessions", new { id = session.SessionId }, null )%><br />
              <% } %>
            </div>
            <div style="clear: both;"></div>
          </div>

          <input type="submit" value="Save my picks" />
        </fieldset>
    <% } %>
  </div>

</asp:Content>

